{include file="common/head"/}
<div class="admin-main layui-anim layui-anim-upbit">
    <form class="layui-form layui-form-pane" lay-filter="form">
        <div class="layui-form-item">
            <label class="layui-form-label">请假原因</label>
            <div class="layui-input-4">
                <div class="layui-input-inline layui-form">
                    <input type="radio" name="leave_reason" value="2" title="病假" checked lay-filter="leave_reason2">
                    <input type="radio" name="leave_reason" value="1" title="事假"  lay-filter="leave_reason1">
                </div>
            </div>

        </div>
        <div class="layui-form-item layui-form-text reason" hidden >
            <label class="layui-form-label">请假原因</label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" class="layui-textarea" name="content" id="content"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">请假时间</label>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="leave_date" placeholder=" - " name="leave_date">
                </div>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" name="teacher_id" value="{$teacher_id}">
                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
            </div>
        </div>
    </form>
</div>
{include file="common/foot"/}
<script>
    layui.use(['form', 'layer','laydate'], function () {
        var form = layui.form,layer = layui.layer,$= layui.jquery;var laydate = layui.laydate;

        //日期范围
        laydate.render({
            elem: '#leave_date'
            ,range: true
        });

        form.on('radio(leave_reason1)', function(data){
            $('.reason').show();
        });
        form.on('radio(leave_reason2)', function(data){
            $('.reason').hide();
        });

        form.on('submit(submit)', function (data) {
            // 提交到方法 默认为本身
            $.post("{:url('leaveAdd')}",data.field,function(res){
                if(res.code > 0){
                    layer.msg(res.msg,{time:1000,icon:1},function(){
                        parent.location.href = res.url;
                    });
                }else{
                    layer.msg(res.msg,{time:1000,icon:2});
                }
            });
        })
    });
</script>